package com.shujia.day16;

import java.io.BufferedInputStream;
import java.io.FileInputStream;

/*
    InputStream:
        FileInputStream【普通的字节输入流】:
        BufferedInputStream【字节缓冲输入流】:
 */
public class BufferedInputStreamDemo1 {
    public static void main(String[] args) throws Exception {
        //BufferedInputStream(InputStream in)
        //创建一个 BufferedInputStream并保存其参数，输入流 in ，供以后使用。
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("java/src/com/shujia/day16/a1.txt"));

        // 一次读一个字节
//        int i = 0;
//        while ((i=bis.read())!=-1){
//            System.out.print((char) i);
//        }

        // 一次都一个字节数组
        byte[] bytes = new byte[1024];
        int length = 0;
        while ((length = bis.read(bytes)) != -1) {
            String s = new String(bytes, 0, length);
            System.out.print(s);
        }


        //释放资源
        bis.close();
    }
}
